/**
 * 设置iframe的高度
 *
 * @param selector
 * @param offset
 */
function setHeight(selector, offset) {
    var bodyHeight = $("body").height();
    var windowHeight = $(window).height();
    var offsetTmp = offset;
    if (offsetTmp) {
    } else {
        offsetTmp = 120;
    }
    if (bodyHeight < windowHeight) {
        $(selector).css(
            "min-height",
            windowHeight - $("#nav_wrapper_div").height()
            - $("#footer_div").height() - offsetTmp);
        $(selector).css("max-height", "none");
    }
}

/**
 * jqgrid专用，用来格式化外链的方法 使用方法参考gtimp\query\shipMentInfoQueryList.jsp中的col：LINK
 *
 * @param cellvalue
 * @param options
 * @param rowObject
 * @returns {String}
 */
function makeUrl(cellvalue, options, rowObject) {
    return "<a href='" + cellvalue + "' target='_blank'>" + cellvalue + "</a>";
}

/**
 * 刷新树的数据
 *
 * @param treeObj
 */
function tree_refresh(treeObj, node) {
    if (node) {
        treeObj.reAsyncChildNodes(null, "refresh");
    } else {
        treeObj.reAsyncChildNodes(node, "refresh");
    }
}
/**
 * 提交树数据
 *
 * @param nodes
 *            需要提交的节点
 * @param url
 *            提交地址
 * @param parameterNames
 *            需要提交的节点参数对象， 如：{ "role.a{n}.id" : "id", "role.b{n}.checked" :
 *            "checked"
 *            }表示提交如下参数role.a[1].id=对应id值,role.b[1].checked=对应checked值,role.a[2].id=对应id值.......
 * @param parameters
 *            需要提交的固定参数
 * @param cod
 *            节点参数通配符
 * @param success
 *            提交成功回调函数
 */

function submitTree(nodes, url, parameterNames, parameters, cod, success) {
    // var changed = zTree.getChangeCheckedNodes();
    var changed = nodes;
    var datav = "";
    if (cod) {
        cod = "{" + cod + "}";
    } else {
        cod = "{n}";
    }
    $.each(changed, function (i, n) {
        $.each(parameterNames, function (j, m) {
            datav += "\"" + j.replace(cod, "[" + i + "]") + "\":\"" + n[m]
                + "\",";
        });
    });
    if (datav) {
        datav = datav.substring(0, datav.length - 1);
    }
    var parm = {};
    if (parameters) {
        $.extend(parm, parameters);
    }
    var parmmod = (new Function("return {" + datav + "}"))();
    $.extend(parm, parmmod);
    $.ajax({
        url: url,
        data: parm,
        success: success,
        type: "post"
    });

}
/**
 * 处理缓存
 * @returns
 */
function timeNum() {
    var ctime = new Date();
    var tdate = ctime.getTime();
    return tdate;
}